package com.engine.annual.cmd;

import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import weaver.common.StringUtil;
import weaver.conn.RecordSet;
import weaver.hrm.User;

import java.util.HashMap;
import java.util.Map;

public class AnnualGetCmd extends AbstractCommonCommand<Map<String, Object>> {

    public AnnualGetCmd(User user, Map<String, Object> params) {
        this.user = user;
        this.params = params;
    }

    @Override
    public BizLogContext getLogContext() {
        return null;
    }

    @Override
    public Map<String, Object> execute(CommandContext commandContext) {

        HashMap<String, Object> apidatas = new HashMap<>();

        HashMap<String, String> userinfo = new HashMap<>();

        RecordSet recordSet = new RecordSet();
        String sql = "select * from t_annual where ID=" + params.get("id") + "and YEAR=" + params.get("year");
        recordSet.execute(sql);
        if (recordSet.next()) {
            userinfo.put("id", recordSet.getString("id"));
            userinfo.put("hrmid", recordSet.getString("hrmid"));
            userinfo.put("year", recordSet.getString("year"));
            userinfo.put("availabledays", recordSet.getString("availabledays"));
            userinfo.put("useddays", recordSet.getString("useddays"));
        }
        apidatas.put("data", userinfo);

        return apidatas;
    }
}
